home *** CD-ROM | disk | FTP | other *** search
/ C/C++ Users Group Library 1996 July / C-C++ Users Group Library July 1996.iso / listings / v_09_11 / 9n11031a < prev    next >
Text File  |  1991-08-26  |  691b  |  31 lines

  1.  
  2. /* --------------------------------------------------------------
  3.  
  4. FUNCTION GET_FREE_NODE: The steps to get a node from the free node
  5.     list are:
  6.  
  7. A.  If the free node list is empty, get memory for a new node and 
  8.     return its address.
  9.  
  10. B.  Else remove the first node from the free list and use that.
  11.  
  12. -------------------------------------------------------------- */
  13.  
  14. Node *get_free_node(void)
  15. {
  16.     const Node *pnew_node;
  17.  
  18. /*A*/    if (pfree_node == NULL) {
  19.         pnew_node = malloc(sizeof(Node));
  20.     }
  21. /*B*/    else {
  22.         pnew_node = pfree_node;
  23.         pfree_node = pfree_node->pfwd;    
  24.     }
  25.  
  26.     return pnew_node;
  27. }
  28.  
  29. /* ----------------------------------------------------------- */
  30.  
  31.